﻿using System.Data.SqlClient;
using PropertyExpression.Common;

namespace PropertyExpression.ControllableQuery
{
    public interface IDataReader<T>
    {
        SqlDataReader SqlDataReader { get; }
    }

    public static class QueryExtensions
    {
        public static IDataReader<T> GetReader<T>(this IQuery<Type<T>> it, SqlDataReader reader)
        {
            return new DataReader<T>(reader);
        }

        private class DataReader<T> : IDataReader<T>
        {
            private readonly SqlDataReader sqlDataReader;

            public SqlDataReader SqlDataReader
            {
                get { return sqlDataReader; }
            }

            public DataReader(SqlDataReader sqlDataReader)
            {
                this.sqlDataReader = sqlDataReader;
            }
        }
    }
}